#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/3/4
import configparser

config = configparser.ConfigParser()  # 声明
config.read("example.ini")

# ########## 改写 ##########
# sec = config.remove_section('bitbucket.org')
# config.write(open('i.cfg', "w"))


# 判断
sec = config.has_section("alex")
if not sec:
    config.add_section("alex")
config["alex"]["age"] = "21"
config.set("alex", "age", "22")  # 修改
config.write(open("example2.ini", "w"))

